package top.truehaku.generator.code.domain.model.code;

import lombok.Getter;
import top.truehaku.generator.common.util.StringUtils;

import java.io.File;

public class CodeFile {

    private String prefix;
    private String entityName;
    private String suffix;
    private String extension;

    public CodeFile(String prefix, String entityName, String suffix, String extension) {
        if(StringUtils.isBlank(entityName)){
            throw new IllegalArgumentException("实体名字不能为空");
        }
        this.prefix = StringUtils.isBlank(prefix)?"":prefix.trim();
        this.entityName = entityName;
        this.suffix = StringUtils.isBlank(suffix)?"":suffix.trim();
        this.extension = StringUtils.isBlank(extension)?"":extension.trim();
    }

    /**
     * 无后缀名字
     * @return
     */
    public String getSimpleName(){
        return this.prefix +
                this.entityName +
                this.suffix
                ;
    }

    /**
     * 无后缀名字 首字母小写
     * @return
     */
    public String getUncapitalizeSimpleName(){
        return StringUtils.uncapitalize(getSimpleName());
    };

    /**
     * 获取文件名字
     * @return
     */
    public String getFilename(){
        return this.getSimpleName()+"."+this.extension;
    }


    public static void main(String[] args) {
        File file = new File("D:\\workspace\\1541569811_20230318_cert\\apiclient_cert.pem");
        System.out.println(file.getPath());
        System.out.println(file.getName());

    }


}
